<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>作业</title>
    <script src="js/jquery-3.3.1.min.js"></script>
    <script>
        $(function () {
            //发送ajax请求，加载所有省份数据
            $.get("/shengf",{},function (data) {
                //1.获取select
                var province = $("#province");
                //2.遍历json数组
                //json对象变成jquery对象
                $(data).each(function () {
                    //3.创建<option>
                    var option = "<option name='"+this.id+"'>"+this.name+"</option>";
                    //4.调用select的append追加option
                    province.append(option);
                })
            });
        });
    </script>
</head>

<body style="background-color: bisque;">
<select id="province">
</select>
</body>
</html>

